<html lang="en">



<head>

  <meta charset="UTF-8">

  <meta http-equiv="X-UA-Compatible" content="IE=edge">

  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title>阿豪传媒</title>

  <style>
    .container {

      min-height: 100vh;

    }



    .container .nav {

      height: 100%;

      background-color: #fff;

    }



    .link-secondary {

      text-decoration: none;

    }



    .link-secondary:hover {

      color: #0d6efd !important;

    }
  </style>

</head>



<body>

  <!-- container 是 bootstrap的居中窄显示方案 -->

  <div class="container bg-transparent">

    <div class="row">

      <div class="col-md-2 leftmenu" id="leftmenu"></div>

      <div class="col-md-9 kc ms-3">

        <div class="row mt-3 pd-1 border-bottom border-secondary">

          <div class="col-md-2">编辑班级</div>

          <div class="col-md-1 offset-md-8">

            <a class="nav-link link-success" href="./index.html">返回</a>

          </div>

        </div>

        <div class="row mt-3">

          <form>

            <div class="mb-3 row">

              <label for="class_code" class="col-sm-2 col-form-label">班级编号</label>

              <div class="col-sm-10">

                <input type="text" class="form-control" id="class_code">

              </div>

            </div>

            <div class="mb-3 row">

              <label for="class_name" class="col-sm-2 col-form-label">班级名称</label>

              <div class="col-sm-10">

                <input type="text" class="form-control" id="class_name">

              </div>

            </div>

            <div class="mb-3 row">

              <label for="grade_code" class="col-sm-2 col-form-label">年级:</label>

              <div class="col-sm-10">

                <select class="form-select" id="grade_code">

                  <option selected>--请选择年级--</option>

                  <option value="1">2021级</option>

                  <option value="2">2022级</option>

                </select>

              </div>

            </div>

            <div class="mb-3 row">

              <label for="class_logo" class="col-sm-2 col-form-label">班级logo</label>

              <div class="col-sm-10">

                <input type="text" class="form-control" id="class_logo">

              </div>

            </div>

            <div class="mb-3 row">

              <label for="class_number" class="col-sm-2 col-form-label">班级人数</label>

              <div class="col-sm-10">

                <input type="text" class="form-control" id="class_number">

              </div>

            </div>

            <div class="mb-3 row">

              <div class="col-sm-12">

                <button type="button" class="btn btn-outline-primary" id="submit">提交</button>

              </div>

            </div>

          </form>

        </div>

      </div>

    </div>

  </div>

  <script type="module" src="../js/main.js"></script>

  <script src="../js/jquery.min.js"></script>

  <script src="../js/common.js"></script>

  <script>

    $(document).ready(function () {

      function getUrlParams(key) {// 获取网址中参数信息"key"中放属性名

        var url = window.location.search.substr(1);

        if (url == '') {

          return false;

        }

        var paramsArr = url.split('&');

        for (var i = 0; i < paramsArr.length; i++) {

          var combina = paramsArr[i].split("=");

          if (combina[0] == key) {

            return combina[1];

          }

        }

        return false;

      }



      $.get(`https://unicloud.codecore.cn/ms/getClass?id=${getUrlParams("id")}`, {}, function (params) {

        console.log(params);

        if (params.errCode == 0) {

          let data = params.data;

          let class_code = $("#class_code").val(data.class_code)

          let class_name = $("#class_name").val(data.class_name)

          let class_logo = $("#class_logo").val(data.class_logo)

          let class_number = $("#class_number").val(data.class_number)

          let grade_code = $("#grade_code").val(data.grade_code)

        }



      })

      $(".btn-outline-primary").click(function () {

        let class_code = $("#class_code").val()

        let class_name = $("#class_name").val()

        let class_logo = $("#class_logo").val()

        let class_number = $("#class_number").val()

        let grade_code = $("#grade_code").val()

        $.post(" https://unicloud.codecore.cn/ms/classUpdate", {

          id: getUrlParams("id"),

          class_code: class_code,

          class_name: class_name,

          class_logo: class_logo,

          class_number: class_number,

          grade_code: grade_code,

          school_code: 50709,

          department_code: 200,

          majors_code: 3

        }, function (params) {

          if (params.errCode == 0) {

            location.href = "./class.html"

          } else {

            alert("添加失败")

          }

        })

      })

    })

  </script>



</body>



</html>